
#include <BOpenGL>

#include <BShader>
#include "member_BShader.h"

using namespace BWE;

#define member					(*(member_BShader*)_ptr)
#define member_allocate()		_ptr = new member_BShader(this)
#define member_release()		delete (member_BShader*)_ptr

BShader::BShader(ShaderType type, const BString& text)
{
	member_allocate();
	member.type = type;
	member.text = text;
	member.dirty = true;
}
BShader::~BShader()
{
	member_release();
}

void BShader::setType(ShaderType type)
{
	if (member.type != type)
	{
		member.type = type;
		member.dirty = true;
	}
}
ShaderType BShader::type() const
{
	return member.type;
}

void BShader::setText(const BString& text)
{
	if (member.text != text)
	{
		member.text = text;
		member.dirty = true;
	}
}
const BString& BShader::text() const
{
	return member.text;
}

void BShader::clear()
{
	if (member.object)
	{
		BOpenGL::ReleaseShaderObject(member.object);
		member.object = 0;
	}
	member.object = 0;
	member.text.clear();
	member.dirty = false;
}

